package Translation;

import TCPThread.TcpThreadPoolEchoServer;

import java.io.IOException;
import java.util.HashMap;

// echo 和 translate 两个服务器之间,大多都是类似的
public class TcpTranslateServer extends TcpThreadPoolEchoServer {
    private HashMap<String,String> map = new HashMap<>();

    public TcpTranslateServer(int port) throws IOException {
        super(port);
        map.put("china","中国");
        map.put("hello","你好");
        map.put("translate","翻译");
    }

    @Override
    public String process(String request) {
        return map.getOrDefault(request,"查无此单词!");
    }

    public static void main(String[] args) throws IOException {
        TcpTranslateServer server = new TcpTranslateServer(9090);
        server.start();
    }
}
